import { DatePicker } from 'antd';
import type { FC } from 'react';

const RangePicker: any = DatePicker.RangePicker;

type TProps = {
  value?: any;
  width?: string;
  format?: string;
  showTime?: boolean;
  onChange: TAnyFunction;
};

const CommonDateRange: FC<TProps> = (props) => {
  const { value, width, onChange, format = 'YYYY-MM-DD', showTime = false } = props;

  return (
    <RangePicker
      placeholder={['开始时间', '结束时间']}
      style={{ width: width || '100%' }}
      value={value}
      format={format}
      onChange={onChange}
      {...(showTime && { showTime })}
    />
  );
};

export default CommonDateRange;
